import { computed, type CSSProperties, type StyleValue } from 'vue'
import { pick } from 'lodash-es'
import { type TextComponentProps } from '@/types/defaultProps'

const useComponentCommon = (
  props: Readonly<Partial<TextComponentProps & { isEditing: boolean }>>,
  picks: string[]
) => {
  const styleProps: any = computed(() => pick(props, picks))
  const handleClick = () => {
    if (props.actionType === 'url' && props.url && !props.isEditing) {
      window.location.href = props.url
    }
  }
  return {
    styleProps,
    handleClick
  }
}

export default useComponentCommon
